package edu.msg.hrappy.backend.service.util;

public class Validator {
	
	
	public static boolean validateString(String input) {
		char[] chars = input.toCharArray();

		for (char c : chars) {
			if (!Character.isLetter(c)) {
				return false;
			}
		}
		if (input.length() >= 3) {
			return true;
		} else {
			return false;
		}
	}
        
        public static boolean validateJobName(String input) {
		char[] chars = input.toCharArray();

		for (char c : chars) {
			if (!Character.isLetter(c) || c ==' ') {
				return false;
			}
		}
		if (input.length() >= 3) {
			return true;
		} else {
			return false;
		}
	}
	
	public static boolean isValidEmailAddress(String email) {
		String ePattern = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";
		java.util.regex.Pattern p = java.util.regex.Pattern.compile(ePattern);
		java.util.regex.Matcher m = p.matcher(email);
		return m.matches();
	}

	public static boolean isNumeric(String str) {
		try {
			Double.parseDouble(str);
		} catch (NumberFormatException nfe) {
			return false;
		}
		if (str.length() >= 10 && str.length() <= 18)
			return true;
		else
			return false;
	}
	
	public static boolean validateText(String input) {
		
		if (input.length() >= 10) {
			return true;
		} else {
			return false;
		}
	}
	
}
